From: Guillaume Desmottes Date: Mon, 27 Jun 2011 12:31:53 +0000 (+0200) Subject: Display the number of unread messages in the notification icon X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~1013^2^2~8095 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=fda8ffd9ef86a887f1276778507a582153a3606c;p=gnome-shell.git Display the number of unread messages in the notification icon https://bugzilla.gnome.org/show_bug.cgi?id=654139 --- diff --git a/js/ui/telepathyClient.js b/js/ui/telepathyClient.js index 8a476011a..b916fac6f 100644 --- a/js/ui/telepathyClient.js +++ b/js/ui/telepathyClient.js @@ -370,6 +370,8 @@ ChatSource.prototype = { this._pendingMessages.push(message); } + this._updateCount(); + let showTimestamp = false; for (let i = 0; i < logMessages.length; i++) { @@ -414,11 +416,16 @@ ChatSource.prototype = { this.destroy(); }, + _updateCount: function() { + this._setCount(this._pendingMessages.length, this._pendingMessages.length > 0); + }, + _messageReceived: function(channel, message) { if (message.get_message_type() == Tp.ChannelTextMessageType.DELIVERY_REPORT) return; this._pendingMessages.push(message); + this._updateCount(); message = makeMessageFromTpMessage(message, NotificationDirection.RECEIVED); this._notification.appendMessage(message); @@ -489,8 +496,10 @@ ChatSource.prototype = { _pendingRemoved: function(channel, message) { let idx = this._pendingMessages.indexOf(message); - if (idx >= 0) + if (idx >= 0) { this._pendingMessages.splice(idx, 1); + this._updateCount(); + } else throw new Error('Message not in our pending list: ' + message); },